package com.yang.controller;

import com.yang.entity.NoteRole;
import com.yang.service.NoteRoleService;
import com.yang.utils.UtilsFactory;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 角色表(NoteRole)表控制层
 *
 * @author yangdacheng
 * @since 2022-03-02 19:11:02
 */
@RestController
@RequestMapping("noteRole")
public class NoteRoleController {
    /**
     * 服务对象
     */
    @Resource
    private NoteRoleService noteRoleService;
    @Resource
    private UtilsFactory utilsFactory;

    /**
     * 添加新的角色
     * @param noteRole
     * @return
     */
    @PostMapping("insertRole")
    public Boolean insertRole(NoteRole noteRole){
        noteRole.setRoleId(utilsFactory.buildID());
        return noteRoleService.insertNoteRole(noteRole);
    }

    /**
     * 查询所有的角色
     * @return
     */
    @GetMapping("queryAllRole")
    public List<NoteRole> queryAllRole(){
        return noteRoleService.queryAllNoteRole();
    }

    /**
     * 根据编号获取对应的角色
     * @param roleID
     * @return
     */
    @GetMapping("queryRoleById/{rid}")
    public NoteRole queryRoleByID(@PathVariable("rid") String roleID){
        return noteRoleService.queryByRID(roleID);
    }
}